package com.shoppingmalltest.shoppingmalltest.product.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/*import org.apache.shiro.authz.annotation.RequiresPermissions;*/
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.shoppingmalltest.shoppingmalltest.product.entity.SubjectEntity;
import com.shoppingmalltest.shoppingmalltest.product.service.SubjectService;
import com.shoppingmalltest.common.utils.PageUtils;
import com.shoppingmalltest.common.utils.R;



/**
 * 课程科目
 *
 * @author libo
 * @email 1666737385@qq.com
 * @date 2020-07-26 13:17:40
 */
@RestController
@RequestMapping("product/subject")
public class SubjectController {
    @Autowired
    private SubjectService subjectService;

    /**
     * 获取所有菜单的子菜单
     */
    @RequestMapping("/list/tree")
  /*  @RequiresPermissions("product:subject:list")*/
    public R list(){
       List<SubjectEntity> list=subjectService.getChildren();
        return R.ok().put("data", list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
  /*  @RequiresPermissions("product:subject:info")*/
    public R info(@PathVariable("id") String id){
		SubjectEntity subject = subjectService.getById(id);

        return R.ok().put("subject", subject);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
  /*  @RequiresPermissions("product:subject:save")*/
    public R save(@RequestBody SubjectEntity subject){
		subjectService.save(subject);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
  /*  @RequiresPermissions("product:subject:update")*/
    public R update(@RequestBody SubjectEntity subject){
		subjectService.updateById(subject);

        return R.ok();
    }

    /**
     * 删除
     * @RequestBody获取请求体的内容
     * 将请求体的内容转换为对象
     */
    @RequestMapping("/delete")
  /*  @RequiresPermissions("product:subject:delete")*/
    public R delete(@RequestBody String[] ids){
		//subjectService.removeByIds(Arrays.asList(ids));
        subjectService.removeMenusByIds(Arrays.asList(ids));
        return R.ok();
    }

}
